﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Web;
using NK.Mvc3.Models;

namespace NK.Mvc3.DBL
{
    public class StoreContext:DbContext
    {
        public DbSet<ProductInfo> ProductInfos { get; set; }

        public DbSet<StoreInput> StoreInputs { get; set; }

        public DbSet<StoreInputDetail> StoreInputDetails { get; set; }

        public DbSet<Sale> Sales { get; set; }

        public DbSet<SaleDetail> SaleDetails { get; set; }

        public DbSet<Statistics> Statistics { get; set; }

        public DbSet<StoreOutput> StoreOutputs { get; set; }

        public DbSet<StoreOutputDetail> StoreOutputDetails { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

            modelBuilder.Entity<ProductInfo>()
                .HasOptional(p => p.Statistics).WithRequired(p => p.ProductInfo);
        }
    }
}